using System;
using EntLibContrib.PostSharp4EntLib.Test.PolicyInjection.RuleDrivenPolicies;

namespace EntLibContrib.PostSharp4EntLib.Test
{
    internal static class VisualTest
    {
        public static void Execute()
        {
            ConsoleColor oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.WriteLine(
                @"

This program is a visual (but not automated) unit test. 
You should verify if all method whose name ends with 
'WithLogging' are logged, and no method whose name 
ends with 'WithoutLogging' is logged.

Each method call is visually enclosed by green separators.

Enjoy!


" );
            Console.ForegroundColor = oldColor;

            InjectPoliciesFromConfiguration o1 = new InjectPoliciesFromConfiguration();
            o1.MethodWithLogging();
            WriteSeparator();
            o1.MethodWithoutLogging();
            WriteSeparator();

            InjectPolicyExplicitely o2 = new InjectPolicyExplicitely();
            o2.MethodWithLogging();
            WriteSeparator();
            o2.MethodWithoutLogging();
            WriteSeparator();

            Interceptable o3 = new Interceptable();
            o3.MethodWithLogging();
            WriteSeparator();
            o3.MethodWithoutLogging();
            WriteSeparator();
        }

        public static void WriteSeparator()
        {
            ConsoleColor oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine( "-----------------------------------------------------------------------------" );
            Console.ForegroundColor = oldColor;
        }

        public static void WriteLine( string format, params object[] args )
        {
            ConsoleColor oldColor = Console.ForegroundColor;
            Console.ForegroundColor = ConsoleColor.Yellow;
            Console.WriteLine( format, args );
            Console.ForegroundColor = oldColor;
        }
    }
}